from django.db import models
from django.contrib.auth.models import User


# Create your models here.
class Autor(models.Model):
	user = models.ForeignKey(User, unique=True, null=True)
	avatar = models.CharField(max_length=20, null=True)
	stopka = models.CharField(max_length=300, null=True)
	rank = models.IntegerField(null=True)
	pseudo = models.CharField(max_length=20)
	def __unicode__(self):
		return self.pseudo

class Adress(models.Model):
	autor = models.ForeignKey(Autor)
	addres = models.CharField(max_length=20)
	data_wiz = models.DateTimeField('data wizytacji')
	def __unicode__(self):
		return self.addres


class Temat(models.Model):
	autor = models.ForeignKey(Autor)
	tytul = models.CharField(max_length=200)
	tresc = models.CharField(max_length=2000)
	data_pub = models.DateTimeField('data publikacji')
	data_up = models.DateTimeField('data ostatniego wpisu')
	def __unicode__(self):
		return self.tytul

	
class Odpowiedz(models.Model):
	autor = models.ForeignKey(Autor)
	temat = models.ForeignKey(Temat)
	tresc = models.CharField(max_length=2000)
	data_pub = models.DateTimeField('data publikacji')
	def __unicode__(self):
		return self.temat.tytul
